package chapter07

object Demo03_MulArray {
  def main(args: Array[String]): Unit = {
    //创建一个二维数组
    val array: Array[Array[Int]] = Array.ofDim[Int](2, 3)

    //访问元素
    array(0)(2) = 99
    array(1)(0) = 88

    //遍历数组
    println(array.mkString(" "))
    //完整遍历
    for (i <- 0 until array.length ; j <- 0 until array(i).length){
      println(array(i)(j))
    }

    for (i <- array.indices ; j <- array(i).indices){
      print(array(i)(j) + "\t")
      if (j == array(i).length-1) println()
    }

    println("===============================")
    array.foreach(line => line.foreach(println))
    array.foreach(_.foreach(println))
  }
}
